/*
 *             Copyright (C) 2024 Steve Jrong
 * 
 * 	   GitHub Homepage: https://www.github.com/SteveJrong
 *      Gitee Homepage: https://gitee.com/stevejrong1024
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *        https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.stevejrong.waiter.business.code.component;

import com.stevejrong.waiter.common.component.ICommonEnum;

import lombok.NoArgsConstructor;

/**
 * 常量类 - 错误码常量类
 * 
 * @author Steve Jrong
 * @since 1.0
 */
@NoArgsConstructor
public final class ErrorCodes {

	/**
	 * 公共错误码
	 * 
	 * @author Steve Jrong
	 * @since 1.0
	 */
	public enum CommonErrorCodes implements ICommonEnum {
		REQUEST_SUCCESSED {

			@Override
			public int code() {
				return 100001;
			}

			@Override
			public String desc() {
				return "请求成功";
			}
		},

		SERVICES_INTERINAL_ERROR {

			@Override
			public int code() {
				return 100002;
			}

			@Override
			public String desc() {
				return "服务器内部错误";
			}
		},

		REMOTE_CALL_SERVICE_IS_NOT_FOUND {

			@Override
			public int code() {
				return 100003;
			}

			@Override
			public String desc() {
				return "远程服务不存在";
			}
		},

		REMOTE_CALL_SERVICE_IS_UNAVALIABLE {

			@Override
			public int code() {
				return 100004;
			}

			@Override
			public String desc() {
				return "远程服务不可用";
			}
		},

		REQUEST_IS_NOT_FOUND {

			@Override
			public int code() {
				return 100005;
			}

			@Override
			public String desc() {
				return "请求不存在";
			}
		},

		REQUEST_METHOD_IS_NOT_SUPPORTED {

			@Override
			public int code() {
				return 100006;
			}

			@Override
			public String desc() {
				return "请求方式不支持";
			}
		},

		REQUEST_PARAMETERS_IS_INVALID {

			@Override
			public int code() {
				return 100007;
			}

			@Override
			public String desc() {
				return "请求参数非法";
			}
		},

		REQUEST_IS_MISSING_FROM_HEADER {

			@Override
			public int code() {
				return 100008;
			}

			@Override
			public String desc() {
				return "缺少请求头参数";
			}
		},

		REQUEST_IS_MISSING_FROM_BUSINESS_PARAMETERS {

			@Override
			public int code() {
				return 100009;
			}

			@Override
			public String desc() {
				return "缺少请求业务参数";
			}
		},

		REQUEST_IS_TIMEOUT {

			@Override
			public int code() {
				return 100010;
			}

			@Override
			public String desc() {
				return "请求超时";
			}
		},

		REQUEST_FREQUENCY_EXCEEDS_THE_LIMIT {

			@Override
			public int code() {
				return 100011;
			}

			@Override
			public String desc() {
				return "请求频次超过上限";
			}
		},

		HAVE_NOT_PERMISSIONS_TO_VISIT_THIS_RESOURCE {

			@Override
			public int code() {
				return 100012;
			}

			@Override
			public String desc() {
				return "没有访问此资源的权限";
			}
		};
	}

	/**
	 * 用户认证相关错误码
	 * 
	 * @author Steve Jrong
	 * @since 1.0
	 */
	public enum AuthcErrorCodes implements ICommonEnum {
		ACCESS_TOKEN_IS_NOT_FOUND_IN_REQUEST_HEADER {

			@Override
			public int code() {
				return 101041;
			}

			@Override
			public String desc() {
				return "请求头中无AccessToken";
			}
		},

		ACCESS_TOKEN_IS_INVALID {

			@Override
			public int code() {
				return 101042;
			}

			@Override
			public String desc() {
				return "AccessToken的格式非法";
			}
		},

		JWT_DECODE_FAILED {

			@Override
			public int code() {
				return 101043;
			}

			@Override
			public String desc() {
				return "JWT解析失败";
			}
		},

		RSA_KEY_VERIFY_FAILED {

			@Override
			public int code() {
				return 101044;
			}

			@Override
			public String desc() {
				return "RSA密钥验证失败";
			}
		},

		ACCESS_TOKEN_IS_EXPIRED {

			@Override
			public int code() {
				return 101045;
			}

			@Override
			public String desc() {
				return "AccessToken已过期";
			}
		},

		ACCESS_TOKEN_IS_ABANDONED {

			@Override
			public int code() {
				return 101046;
			}

			@Override
			public String desc() {
				return "AccessToken已废弃";
			}
		},

		REFRESH_TOKEN_IS_INVALID {

			@Override
			public int code() {
				return 101047;
			}

			@Override
			public String desc() {
				return "RefreshToken的格式非法";
			}
		},

		REFRESH_TOKEN_IS_EXPIRED {

			@Override
			public int code() {
				return 101048;
			}

			@Override
			public String desc() {
				return "RefreshToken已过期";
			}
		};
	}
}
